#pragma once

#include <QtWidgets/QMainWindow>
#include "ui_cj_player.h"
#include <QtMultimedia/qmediaplayer.h>
#include <QtMultimedia/qmultimedia.h>
#include <QtMultimediaWidgets/qvideowidget.h>
#include <QtMultimedia/qmediaplaylist.h>

class cj_player : public QMainWindow
{
	Q_OBJECT

public:
	cj_player(QWidget *parent = Q_NULLPTR);
	struct MediaData
	{
		QString url;
		QString name;
		double playTo;
	};
private:
	Ui::cj_playerClass ui;
	QMediaPlayer * m_player;
	QVideoWidget *m_vdWidget;
	QMediaPlaylist *m_playList;
	QVector<MediaData> m_mediaDatas;
	QString GetName(QString url);
	qint64 m_duration;
public slots:
	void OnOpenTriggered();
	void OnPlayTriggered();
	void OnPauseTriggered();
	void OnStopTriggered();
	void OnNextTriggered();
	void OnLastTriggered();
	void OnCurrentMediaChanged(const QMediaContent &content);
	void OnVolumeChanged(int value);
	void OnPlaybackChanged(int index);
	void OnStateChanged(QMediaPlayer::State state);
	void OnListWidgetClicked(QListWidgetItem *item);
	void OnPositionChanged(qint64 position);
};
